package com.hyz.login.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hyz.login.model.Hospitalprice;
import com.hyz.login.mapper.HospitalpriceMapper;
import com.hyz.login.service.HospitalpriceService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zwq
 * @since 2022-11-30
 */
@Service
public class HospitalpriceServiceImpl
        extends ServiceImpl<HospitalpriceMapper, Hospitalprice> implements HospitalpriceService {

    @Autowired
    private HospitalpriceMapper hospitalpriceMapper;

    @Override
    public IPage<Hospitalprice> findByRegId(Integer registerId,Integer state, Integer page, Integer limit) {
        QueryWrapper<Hospitalprice> wrapper = new QueryWrapper<Hospitalprice>();
        wrapper.eq("registerId",registerId);
        wrapper.eq("state",state);
        IPage<Hospitalprice> iPage = new Page<Hospitalprice>();
        iPage.setRecords(hospitalpriceMapper.findByRegId(registerId,state, page-1, limit));
        iPage.setTotal(hospitalpriceMapper.selectCount(wrapper));
        iPage.setCurrent(page);
        iPage.setSize(limit);
        return iPage;
    }

    @Override
    public Integer delDrugs(Integer hospitalpriceid) {
        return hospitalpriceMapper.deleteById(hospitalpriceid);
    }

    @Override
    public Integer addDrug(Hospitalprice hospitalprice) {
        return hospitalpriceMapper.addDrug(hospitalprice);
    }
}
